package com.wander.patterns.act.iterator;

import java.util.ArrayList;
import java.util.List;

/**
 * @description:迭代期模式示例
 * @author: zhuyong
 * @create: 2019-09-07 17:23
 **/
public class Client {
    public static void main(String[] args) {
        List<Object> list = new ArrayList<>();
        list.add("a");
        list.add("b");
        list.add("c");
        list.add("d");
        list.add("e");
        list.add("f");
        list.add("g");

        ConcreteMyAggregate concreteMyAggregate = new ConcreteMyAggregate(list);
        ConcreteMyAggregate.ConcreteIterator concreteIterator = concreteMyAggregate.getConcreteIterator();
        while (concreteIterator.hasNext()){
            System.out.println(concreteIterator.isFirst());//是否先调用了next() 方法而定
            System.out.println(concreteIterator.next()+":"+concreteIterator.isFirst());
             System.out.println(concreteIterator.getCursor()+":"+concreteIterator.next()+concreteIterator.first());

        }
    }
}
